package com.wxjfh.Utils;

import com.wxjfh.bean.Admin;
import com.wxjfh.bean.Student;

import java.util.ArrayList;
import java.util.List;

/**
 * 工具类
 * 存放学生集合
 * 提供获取学生集合和添加学生方法
 * 后续添加功能请补上说明
 */
public class DataUtils {
    private static List<Admin> admins = new ArrayList<>();
    private static List<Student> stuList = new ArrayList<>();
    public static void addAdmin(Admin admin) {

        admins.add(admin);
    }
    public static Admin queryAdmin(String username, String password) {
        for (Admin admin : admins) {
            if (admin.getUsername().equals(username) && admin.getPassword().equals(password)) {

                return admin;
            }
        }
        return null;
    }


    public static boolean addStu(Student student){
        System.out.println("添加" + student.getName());
        return stuList.add(student);
    }

    public static List<Student> queryStu(){
        return stuList;
    }

    public static boolean removeStu(String studentName) {
        for (Student student : stuList) {
            if (student.getName().equals(studentName)){
                System.out.println("删除" + studentName);
                return stuList.remove(student);
            }
        }
        return false;
    }
}
